<?php

namespace App\Models\Log;

use App\Models\Conf\Agent;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;

class AgentWithdrawalFlow extends Model
{

    /**
     * @Message('申请中')
     */
    const STATUS_APPLY = 0;
    /**
     * @Message('审核通过')
     */
    const STATUS_AUDIT = 1;
    /**
     * @Message('注销申请')
     */
    const STATUS_CANCEL = -1;

    public $table = 'log_agent_withdrawal_flows';

    protected $guarded = [];

    protected $appends = ['status_transform'];


    public function agent()
    {
        return $this->belongsTo(Agent::class, 'agent_id');
    }

    public function auditor()
    {
        return $this->belongsTo(User::class, 'audit_account_id', 'id');
    }

    public function getStatusTransformAttribute()
    {
        switch ($this->status) {
            case self::STATUS_CANCEL:
                return '注销申请';
            case self::STATUS_APPLY:
                return '申请中';
            case self::STATUS_AUDIT:
                return '审核通过';
        }
    }

    /**
     * gameapi
     * 2018/10/9 21:22
     * Administrator
     * getConstants
     * 获取模型常量
     * @return array
     */
    public function getConstants()
    {
        $reflect = new \ReflectionClass(get_class($this));
        return $reflect->getConstants();
    }


}
